#define _CRT_SECURE_NO_WARNINGS 1

//li06_05.cpp

#include"li06_05.h"
#include<iomanip>

using namespace std;

Array::Array(int n)
{
	num = n;
	m = new int[num];
	if (m == NULL)
	{
		cout << "allocation failure.\n";
		exit(0);
	}
	for (int i = 0; i < num; i++)
	{
		m[i] = i * 10 + 1;
	}
}

Array::~Array()
{
	delete[] m;
}

void Array::show()
{
	for (int i = 0; i < num; i++)
	{
		cout << setw(4) << m[i];
	}
	cout << endl;
}

int& Array::operator[](int r)
{
	if (r >= 0 && r < num)
	{
		return *(m + r);
	}
	return *m;
}